package com.zgz.underwrite.util;

import java.math.BigDecimal;

import com.zgz.underwrite.model.PremiumCoef;

public class CalPremiumHelper{

	private PremiumCoef premiumCoef;
	
	public CalPremiumHelper(){
		
	}
	public CalPremiumHelper(PremiumCoef premiumCoef){
		this.premiumCoef = premiumCoef;
	}
	
	/**
	 * 获取交强险的优惠系数总计
	 * @return
	 */
	public Double getTrafTolCoef(){
		Double tolCoef = this.premiumCoef.getNTrafficAccident()* this.premiumCoef.getNSafetyIllegal();
		BigDecimal   b   =   new   BigDecimal(tolCoef);
		b.setScale(2,   BigDecimal.ROUND_HALF_UP);//保留小数点后两位
		return b.doubleValue();
	}
	
	/**
	 *计算交强险的保费(折后的)
	 * @return
	 */
	public Double getTrafPrem(Double rate){
		Double prem = rate*this.getTrafTolCoef(); //计算公式
		BigDecimal b = new BigDecimal(prem);
		b.setScale(2, BigDecimal.ROUND_HALF_UP);
		return b.doubleValue();
	}

	public void setPremiumCoef(PremiumCoef premiumCoef) {
		this.premiumCoef = premiumCoef;
	}

	public PremiumCoef getPremiumCoef() {
		return premiumCoef;
	}
}
